package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

/**
 * @author ttao
 * @since 2023/4/27 11:03
 */

@Mapper
public interface UserMapper {
    @Select("select * from user where openid=#{openId}")
    User selectByOpenId(String openId);

    /**
     * 添加用户
     *
     * @param user
     * @return
     */
    @Options(keyProperty = "id", useGeneratedKeys = true)
    @Insert("insert into user(openid, name, phone, sex, id_number, avatar, create_time) VALUES " +
            "(#{openid},#{name},#{phone},#{sex},#{idNumber},#{avatar},#{createTime})")
    int insert(User user);
}
